<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <title>发布评价</title>
    <link rel="icon" href="./img/favicon.ico">

	<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <link rel="stylesheet" type="text/css" href="./css/all.css" />
    <link rel="stylesheet" type="text/css" href="./css/pages-application.css" />
    <link rel="stylesheet" type="text/css" href="./css/pages-mycomment.css" />
	<style>
		.avatar-uploader .el-upload {
			border: 1px dashed #d9d9d9;
			border-radius: 6px;
			cursor: pointer;
			position: relative;
			overflow: hidden;
		}
		.avatar-uploader .el-upload:hover {
			border-color: #409EFF;
		}
		.avatar-uploader-icon {
			font-size: 28px;
			color: #8c939d;
			width: 150px;
			height: 150px;
			line-height: 150px;
			text-align: center;
		}
		.avatar {
			width: 150px;
			height: 150px;
			display: block;
		}

	</style>
</head>

<body>
    <!-- 头部栏位 -->
    <!--页面顶部-->
<div id="nav-bottom">
	<!--顶部-->
	<div id="appu">
	<div class="nav-top">
		<div class="top">
			<div class="py-container">
				<div class="shortcut">
					<ul class="fl">
						<li class="f-item">商城欢迎您！</li>
						<li class="f-item">{{username}} </li>
					</ul>
					<div class="fr typelist">
						<ul class="types">
							<li class="f-item"><span>我的订单</span></li>
							
							<li class="f-item"><span><a href="cart.html" target="_blank">我的购物车</a></span></li>
							<li class="f-item"><span><a href="home.html" target="_blank">我的商城</a></span></li>			
							<li class="f-item"><span>商城会员</span></li>						
							<li class="f-item"><span>企业采购</span></li>						
							<li class="f-item"><span>关注商城</span></li>
							<li class="f-item"><span><a href="cooperation.html" target="_blank">合作招商</a></span></li>
							<li class="f-item"><span><a href="shoplogin.html" target="_blank">商家后台</a></span></li>				
							<li class="f-item"><span><a href="home.html" target="_blank">个人中心</a></span></li>
						</ul>
					</div>
					
				</div>
			</div>
		</div>

		<!--头部-->
		<div class="header">
			<div class="py-container">
				<div class="yui3-g Logo">
					<div class="yui3-u Left logoArea">
						<a class="logo-bd" title="商城" href="index.html" target="_blank"></a>
					</div>
					<div class="yui3-u Rit searchArea">
						<div class="search">
							<form action="" class="sui-form form-inline">
								<!--searchAutoComplete-->
								<div class="input-append">
									<input type="text" id="autocomplete" class="input-error input-xxlarge" />
									<button class="sui-btn btn-xlarge btn-danger" type="button">搜索</button>
								</div>
							</form>
						</div>
					</div>
					
				</div>

			</div>
		</div>
	</div>
	</div>
</div>

    <!-- 评价订单 -->
    <div id="app" class="mycomment">
        <div class="py-container">
            <div class="head">
                <p class="tit">评价订单</p>
                <p class="num"><span class="gray">订单号：</span>{{orderData.id}}&nbsp;&nbsp;&nbsp;&nbsp;<span class="gray">{{orderData.updateTime}}</span></p>
            </div>
            <div class="service">
                <div class="left">
                    <div class="inner">
<!--                        <img src="./img/_/bg-who1.png" />-->
<!--                        <div class="text">-->
<!--                            <p class="title">配送服务</p>-->
<!--                            <p class="gray">羞涩的配送小哥还没更新个人信息</p>-->
<!--                        </div>-->
                        <div style="clear:both"></div>
                    </div>
                </div>
                <div class="stars">
                    <ul>
<!--                        <li>快递包装</li>-->
<!--                        <li>送货速度</li>-->
<!--                        <li>配送员服务态度</li>-->
                    </ul>
                </div>
                <div style="clear:both"></div>
            </div>
            <div style="clear:both"></div>
            <div class="goods">
                <div class="good-item">
                    <div class="left">
                        <div class="img-intro">
                            <img :src=orderItemData.image />
                            <p>商品名：{{orderItemData.name}}</p>
                            <p>价格：¥{{orderItemData.money}}</p>
<!--                            <p class="gray">3层100抽*8包（柔滑）</p>-->
                        </div>
                    </div>
					<div class="right">
						<div class="block">
							<span class="demonstration">商品评分</span>
							<el-rate v-model="productScore"></el-rate>
						</div>
						<div class="block">
							<span class="demonstration">服务评分</span>
							<el-rate v-model="serviceScore"></el-rate>
						</div>
						<div class="block">
							<span class="demonstration">物流评分</span>
							<el-rate v-model="expressScore"></el-rate>
						</div>
						<p class="warn">请填写商品的评价</p>
						<el-form>
						<el-form-item label="图片">
							<el-upload
									class="avatar-uploader"
									action="/upload/native.do"
									:limit="5"
									:file-list="fileList"
									:show-file-list="true"
									multiple
									:on-success="handleAvatarSuccess"
									:before-upload="beforeAvatarUpload">
								<img v-if="imageUrl1" :src="imageUrl1" class="avatar">
								<i v-else class="el-icon-plus avatar-uploader-icon"></i>
							</el-upload>
						</el-form-item>
						</el-form>



<!--						<div>-->
<!--							<el-upload-->
<!--									action-->
<!--									drag-->
<!--									class="upload-demo"-->
<!--									:on-exceed="handleExceed"-->
<!--									:limit="5"-->
<!--									:file-list="fileList"-->
<!--									:on-change="change"-->
<!--									multiple-->
<!--									:http-request="uploadFile"-->
<!--							>-->
<!--								<i class="el-icon-upload"></i>-->
<!--								<div class="el-upload__text">-->
<!--									将文件拖到此处，或-->
<!--									<em>点击上传</em>-->
<!--								</div>-->
<!--								<div class="el-upload__tip" slot="tip">只能上传txt文本文件,内容按行输入IMEL!</div>-->
<!--							</el-upload>-->
<!--						</div>-->






                        <div class="summary-wrap clearfix">

<!--                            <dl>-->
<!--                                <dt style="vertical-align:middle">评价晒单</dt>-->
<!--                                <div class="input">-->
<!--                                    <div class="demo">-->
<!--                                        <div id="default-demo"></div>-->
<!--                                    </div>-->
<!--                                </div>-->
<!--                            </dl>-->
<!--                            <dl class="tags">-->
<!--								<dt>-->
<!--									<div class="title">-->
<!--										<i>卖家印象</i>-->
<!--									</div>-->
<!--								</dt>-->
<!--								<dd><a href="javascript:;" class="selected">纸不错<span title="点击取消选择">&nbsp;</span></a>-->
<!--								</dd>-->
<!--								<dd><a href="javascript:;">质量好<span title="点击取消选择"-->
<!--																	style="display: none">&nbsp;</span></a></a>-->
<!--								</dd>-->
<!--								<dd><a href="javascript:;">比超市便宜<span title="点击取消选择" style="display: none">&nbsp;</span></a></a>-->
<!--								</dd>-->
<!--								<dd><a href="javascript:;">韧性好<span title="点击取消选择"-->
<!--																	style="display: none">&nbsp;</span></a></a>-->
<!--								</dd>-->
<!--								<dd><a href="javascript:;">没有纸屑<span title="点击取消选择" style="display: none">&nbsp;</span></a></a>-->
<!--								</dd>-->
<!--								<dd><a href="javascript:;">纸质柔软<span title="点击取消选择" style="display: none">&nbsp;</span></a></a>-->
<!--								</dd>-->
<!--							</dl>&lt;!&ndash;虚假的信息之一&ndash;&gt;-->

							<dl>
                                <dt>评价晒单</dt>
                                <div class="input"><textarea v-model="comment" id="inputComment" name="inputComment" placeholder="商品是否给力？快分享你的购物心得吧~"></textarea></div>
                            </dl>
                        </div>
                    </div>
                    <div style="clear:both"></div>
                </div>
            </div>
            <div class="submit">
<!--                <button class="sui-btn btn-danger btn-submit" @click="submit()">提交</button>-->
				<template>
					<el-button class="sui-btn btn-danger btn-submit" type="text" @click="submit()">提交</el-button>
				</template>
				<el-switch
						v-model="isAnonymous"
						active-color="#13ce66"
						active-text="实名评价"
						inactive-text="匿名评价"
						inactive-color="#ff4949">
				</el-switch>
            </div>
            
        </div>
    </div>

    <!-- 底部栏位 -->
    <!--页面底部-->
<div class="clearfix footer">
	<div class="py-container">
		<div class="footlink">
			<div class="Mod-service">
				<ul class="Mod-Service-list">
					<li class="grid-service-item intro  intro1">

						<i class="serivce-item fl"></i>
						<div class="service-text">
							<h4>正品保障</h4>
							<p>正品保障，提供发票</p>
						</div>

					</li>
					<li class="grid-service-item  intro intro2">

						<i class="serivce-item fl"></i>
						<div class="service-text">
							<h4>正品保障</h4>
							<p>正品保障，提供发票</p>
						</div>

					</li>
					<li class="grid-service-item intro  intro3">

						<i class="serivce-item fl"></i>
						<div class="service-text">
							<h4>正品保障</h4>
							<p>正品保障，提供发票</p>
						</div>

					</li>
					<li class="grid-service-item  intro intro4">

						<i class="serivce-item fl"></i>
						<div class="service-text">
							<h4>正品保障</h4>
							<p>正品保障，提供发票</p>
						</div>

					</li>
					<li class="grid-service-item intro intro5">

						<i class="serivce-item fl"></i>
						<div class="service-text">
							<h4>正品保障</h4>
							<p>正品保障，提供发票</p>
						</div>

					</li>
				</ul>
			</div>
			<div class="clearfix Mod-list">
				<div class="yui3-g">
					<div class="yui3-u-1-6">
						<h4>购物指南</h4>
						<ul class="unstyled">
							<li>购物流程</li>
							<li>会员介绍</li>
							<li>生活旅行/团购</li>
							<li>常见问题</li>
							<li>购物指南</li>
						</ul>

					</div>
					<div class="yui3-u-1-6">
						<h4>配送方式</h4>
						<ul class="unstyled">
							<li>上门自提</li>
							<li>211限时达</li>
							<li>配送服务查询</li>
							<li>配送费收取标准</li>
							<li>海外配送</li>
						</ul>
					</div>
					<div class="yui3-u-1-6">
						<h4>支付方式</h4>
						<ul class="unstyled">
							<li>货到付款</li>
							<li>在线支付</li>
							<li>分期付款</li>
							<li>邮局汇款</li>
							<li>公司转账</li>
						</ul>
					</div>
					<div class="yui3-u-1-6">
						<h4>售后服务</h4>
						<ul class="unstyled">
							<li>售后政策</li>
							<li>价格保护</li>
							<li>退款说明</li>
							<li>返修/退换货</li>
							<li>取消订单</li>
						</ul>
					</div>
					<div class="yui3-u-1-6">
						<h4>特色服务</h4>
						<ul class="unstyled">
							<li>夺宝岛</li>
							<li>DIY装机</li>
							<li>延保服务</li>
							<li>品优购E卡</li>
							<li>品优购通信</li>
						</ul>
					</div>
					<div class="yui3-u-1-6">
						<h4>帮助中心</h4>
						<img src="./img/wx_cz.jpg">
					</div>
				</div>
			</div>
			<div class="Mod-copyright">
				<ul class="helpLink">
					<li>关于我们<span class="space"></span></li>
					<li>联系我们<span class="space"></span></li>
					<li>关于我们<span class="space"></span></li>
					<li>商家入驻<span class="space"></span></li>
					<li>营销中心<span class="space"></span></li>
					<li>友情链接<span class="space"></span></li>
					<li>关于我们<span class="space"></span></li>
					<li>营销中心<span class="space"></span></li>
					<li>友情链接<span class="space"></span></li>
					<li>关于我们</li>
				</ul>
				<p>地址：北京市昌平区建材城西路金燕龙办公楼一层 邮编：100096 电话：400-618-4000 传真：010-82935100</p>
				<p>京ICP备08001421号京公网安备110108007702</p>
			</div>
		</div>
	</div>
</div>
<!--页面底部END-->


	<script src="/js/vue.js"></script>
	<script src="/js/axios.js"></script>
<!--	<script src="/js/elementui.js"></script>-->
	<script src="https://unpkg.com/element-ui/lib/index.js"></script>
	<script src="/js/util.js"></script>

<script>
	new Vue({
		el: "#app",
		data() {
			return {
				orderData: {},
				imageUrl:'',
				formVisible: false,
				orderItemData: {},
				userName: '',
				orderId: '',
				searchMap: {},
				currentPage: 1,
				size: 10,
				productScore: 5,
				serviceScore: 5,
				expressScore: 5,
				comment:"",
				isAnonymous:true,
				skuId:'',
				anonymous:'',
				imageUrl1:'',

				fileList: [],
				res: "",
				result: ""



			}
		},
		created(){
			this.orderId=getQueryString("orderId");
			this.skuId=getQueryString("skuId");
			console.log(this.skuId);
			this.fetchData();
			this.searchMap={orderId:this.orderId};
			this.fetchData1();

		},
		methods:{
			// ****图片上传相关代码  如页面有图片上传功能放开注释 ****
			handleAvatarSuccess(res, file) {
				if (this.imageUrl === "")
					this.imageUrl = file.response;
				else
					this.imageUrl += "," + file.response;
			},
			beforeAvatarUpload(file) {
				const isJPG = file.type === 'image/jpeg';
				const isLt2M = file.size / 1024 / 1024 < 2;

				if (!isJPG) {
					this.$message.error('上传图片只能是 JPG 格式!');
				}
				if (!isLt2M) {
					this.$message.error('上传图片大小不能超过 2MB!');
				}
				return isJPG && isLt2M;
			},
			fetchData(){
				axios.get(`/order/findById.do?id=${this.orderId}`).then(response => {
					this.orderData = response.data;
					console.log(response.data);
					// console.log("asd");
				});
			},
			fetchData1(){
				axios.get(`/orderItem/findByOrderId.do?orderId=${this.orderId}`).then(response=>{
					this.orderItemData=response.data;
					console.log(response.data);
				})
			},

			submit(){
				this.searchMap['productScore'] = this.productScore;
				this.searchMap['serviceScore'] = this.serviceScore;
				this.searchMap['expressScore'] = this.expressScore;
				this.searchMap['replyContent']=this.comment;

				if(this.isAnonymous){this.anonymous='1'}
				else if(!this.isAnonymous){this.anonymous='0'}
				this.searchMap['isAnonymous']=this.anonymous;
				this.searchMap['orderId']=this.orderId;
				this.searchMap['image']=this.imageUrl;
				this.searchMap['skuId']=this.skuId;
				console.log(this.searchMap);

				
				axios.post(`/productReply/add1.do`, {
					"orderId": this.orderId,
					"skuId":this.skuId,
					"image":this.imageUrl,
					"replyContent":this.comment,
					"productScore":this.productScore,
					"serviceScore":this.serviceScore,
					"expressScore":this.expressScore,
					"isAnonymous":this.isAnonymous,
				})
				this.$alert('<strong>您已完成评价</strong>', '请确认', {
					dangerouslyUseHTMLString: true
				});
				location.href="/index.do";

			},



			uploadFile() {
				let formData = new FormData();
				if (this.fileList.length > 0) {
					this.fileList.forEach(file => {
						formData.append("file", file);
					});
					if (formData.getAll("file").length == this.length && this.length > 0) {
						this.$http.post("decodeRecode/decodeMore.zul", formData).then(res => {
							this.fileList = [];
							//此处重置文件中间存储变量是为了相同文件能够重复传递
							switch (res.data[0].code) {
								case 0:
									this.res = res.data[0].path;
									this.$message({
										message: "上传成功,可以进行下载!",
										type: "success"
									});
									this.result = encodeURIComponent(this.res);
									window.open(
											`http://192.168.99.91:8080/xsl-decode/decodeRecode/downMd5.zul?path=${this.result}&id=${localStorage.id}`
									);
									this.fileList = [];
									break;
								case 16:
									this.fileList = [];
									this.$message({
										message: "未查到该解码数据!",
										type: "error"
									});
									break;
								case 15:
									this.fileList = [];
									this.$message({
										message: "文件异常!",
										type: "error"
									});
									break;
								case 14:
									this.$message({
										message: "账户不存在该用户!",
										type: "error"
									});
									this.fileList = [];
									break;
								case 13:
									this.$message({
										message: "余额不足请充值!",
										type: "error"
									});
									this.fileList = [];
									break;
								case 1:
									this.$message({
										message: "内容有误,请换个文件!",
										type: "error"
									});
									this.fileList = [];
									break;
								default:
									this.$message({
										message: "服务器偷懒了,请稍后再试!",
										type: "error"
									});
									this.fileList = [];
							}
						});
					}
				}
			},
			change() {
				//判断上传文件数量
				this.length = document.querySelector("input[type=file]").files.length;
				if (this.length > 0) {
					Array.from(document.querySelector("input[type=file]").files).forEach(
							file => {
								if (this.fileList.indexOf(file) == -1) {
									this.fileList.push(file);
								}
							}
					);
				}
				return false;
			},
		}
	})
	new Vue({
		el:'#appu',
		data(){
			return{
				username:''
			}
		},
		created(){
			axios.get(`/login/username.do`).then(response =>{
				this.username=response.data.username;
			});
		},
		methods:{

		}
	})
</script>

</body>

</html>